import pdfplumber
f=pdfplumber.open('test.pdf')
page=f.pages[0]
imgs=page.images
for i,img in enumerate(imgs):
    size=img['width'],img['height']
    data=img['stream'].get_data()
    out=f'{i}.png'
    g=open(out,'wb')
    g.write(data)
f.close()
